﻿<%@ Page Title="Thêm mới hợp đồng" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="New.aspx.cs" Inherits="QuanLyHopDong.Web.HopDong.New" %>
<%@ Import Namespace="Resources" %>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%=GlobalStrings.AddNew %> hợp đồng</h2>
    <p></p>
    <span class="failureNotification">
        <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></span>
    <div id="newHopDongForm">
        Nhân viên xử lý: <asp:DropDownList ID="ddlEmployees" runat="server"></asp:DropDownList>
        <table>
            <tr>
                <td style="vertical-align: top;">
                    <div style="margin-right: 50px; vertical-align: top;">
                        <p>
                            <label>Số HĐ:</label>
                            <asp:TextBox ID="txtSoHopDong" runat="server" CssClass="textEntry name"></asp:TextBox>
                        </p>
                        <p>
                            <label>Tên HĐ:</label>
                            <asp:TextBox ID="txtTenHopDong" runat="server" CssClass="textEntry name"></asp:TextBox>
                        </p>
                        <p>
                            <label>Ngày ký:</label>
                            <asp:TextBox ID="txtNgayKy" runat="server" CssClass="textEntry date datepicker"></asp:TextBox>
                        </p>
                        <p>
                            <label>Ngày bắt đầu thi công:</label>
                            <asp:TextBox ID="txtNgayBatDauThiCong" runat="server" CssClass="textEntry date datepicker"></asp:TextBox>
                        </p>
                        <p>
                            <label>Ngày kết thúc thi công:</label>
                            <asp:TextBox ID="txtNgayKetThucThiCong" runat="server" CssClass="textEntry date datepicker"></asp:TextBox>
                        </p>
                        <p>
                            <label>Giá trị hợp đồng chưa VAT:</label>
                            <asp:TextBox ID="txtGiaTriHopDongChuaVAT" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Tổng giá trị hợp đồng:</label>
                            <asp:TextBox ID="txtTongGiaTriHopDong" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Tình trạng hợp đồng:</label>
                            <asp:DropDownList ID="ddlTrangThaiHopDong" runat="server">
                                <asp:ListItem Value="1">Chưa ký hợp đồng</asp:ListItem>
                                <asp:ListItem Value="2">Đã ký, đang thi công</asp:ListItem>
                                <asp:ListItem Value="3">Đang hoàn công</asp:ListItem>
                                <asp:ListItem Value="4">Đang quyết toán</asp:ListItem>
                                <asp:ListItem Value="5">Hoàn thiện</asp:ListItem>
                            </asp:DropDownList>
                        </p>
                        <p>
                            <label>Ngày hoàn thiện:</label>
                            <asp:TextBox ID="txtNgayHoanThien" runat="server" CssClass="textEntry date datepicker"></asp:TextBox>
                        </p>
                    </div>
                </td>
                <td style="vertical-align: top;">
                    <div style="vertical-align: top;">
                        <p>
                            <label>Đơn vị:</label>
                            <asp:TextBox ID="txtTenDonVi" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Loại dự án:</label>
                            <asp:TextBox ID="txtLoaiDuAn" runat="server" CssClass="textEntry name"></asp:TextBox>
                        </p>
                        <p>
                            <label>Giá trị vật tư:</label>
                            <asp:TextBox ID="txtGiaTriVatTu" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Giá trị nhân công:</label>
                            <asp:TextBox ID="txtGiaTriNhanCong" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Chi phí khác:</label>
                            <asp:TextBox ID="txtChiPhiKhac" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>VAT:</label>
                            <asp:TextBox ID="txtVat" runat="server" CssClass="textEntry date validate[number]"></asp:TextBox>
                        </p>
                        <p>
                            <label>File hợp đồng:</label>
                            <asp:FileUpload ID="fileHopDong" runat="server" /><br/>
                            <asp:FileUpload ID="fileHopDong2" runat="server" /><br/>
                            <asp:FileUpload ID="fileHopDong3" runat="server" /><br/>
                            <asp:FileUpload ID="fileHopDong4" runat="server" />
                        </p>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    
    <div>
        <p>
            <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:GlobalStrings, Save %>"
                CssClass="submitButton" OnClick="btnSave_Click" />
            <input id="btnCancel" type="button" value="<%=GlobalStrings.Cancel %>"
                class="submitButton" onclick="javascript: window.location = 'List.aspx';" />
        </p>
    </div>

    <script type="text/javascript">
        $(function () {
            $(window.theForm).validationEngine();
            
            $("#<%=txtNgayKy.ClientID %>").calendar({ timeSeparators: null });
            $("#<%=txtNgayBatDauThiCong.ClientID %>").calendar({ timeSeparators: null });
            $("#<%=txtNgayKetThucThiCong.ClientID %>").calendar({ timeSeparators: null });
            $("#<%=txtNgayHoanThien.ClientID %>").calendar({ timeSeparators: null });
            $("#<%=txtTenDonVi.ClientID %>").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "/DanhMuc/DonVi/Default.aspx/SearchDonVis",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
        });
        
        function split(val) {
            return val.split(/,\s*/);
        }

        function extractLast(term) {
            return split(term).pop();
        }
    </script>
</asp:Content>
